]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
network: Handle interface name changes
authorFabrice Bellet <fabrice@bellet.info>
Tue, 7 May 2019 15:21:09 +0000 (15:21 +0000)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 7 May 2019 15:21:09 +0000 (15:21 +0000)
The interface name when a device is added may not be the final one. For
example when using USB tethering, it will first appear as 'usb0' before
being renamed to something like 'enp0s20f0u1' depending on the port the
phone is plugged in.

As a result, we will ignore the new interface name in that case and fail
to associate the correct connection with the device: Instead of the
correct "USB Ethernet" (or user-customized name), it will show up as
"Ethernet".

Fix this by updating names and connections when a device's interface
property changes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/534

js/ui/status/network.js

index 9354183d312bb10ac4a9b8d20bc72e94baaf56c6..b24d608e449b6e2b217c4a083d9a8bcc48a99fc2 100644 (file)
@@ -1731,14 +1731,24 @@ var NMApplet = class extends PanelMenu.SystemIndicator {
             this._addDeviceWrapper(wrapper);
 
             this._nmDevices.push(device);
-            if (!skipSyncDeviceNames)
-                this._syncDeviceNames();
+            this._deviceChanged(device, skipSyncDeviceNames);
 
-            if (wrapper instanceof NMConnectionSection) {
-                this._connections.forEach(connection => {
-                    wrapper.checkConnection(connection);
-                });
-            }
+            device.connect('notify::interface', () => {
+                this._deviceChanged(device, false);
+            });
+        }
+    }
+
+    _deviceChanged(device, skipSyncDeviceNames) {
+        let wrapper = device._delegate;
+
+        if (!skipSyncDeviceNames)
+            this._syncDeviceNames();
+
+        if (wrapper instanceof NMConnectionSection) {
+            this._connections.forEach(connection => {
+                wrapper.checkConnection(connection);
+            });
         }
     }